var path = require("path");
var webpack = require("webpack");
const Components = require("./components.json");
const baseConfig = require("./webpack.base.config");
const merge = require("webpack-merge");
module.exports = merge.merge(baseConfig, {
    entry: Components,
    output: {
        path: path.resolve(__dirname, "./distComponents"),
        filename: "[name].min.js",
        chunkFilename: "[id].js",
    },
    resolve: {
        alias: {
            vue$: "vue/dist/vue.esm.js",
        },
        extensions: ["*", ".js", ".vue", ".json"],
    },
    devServer: {
        historyApiFallback: true,
        noInfo: true,
        overlay: true,
    },
});

if (process.env.NODE_ENV === "production") {
    module.exports.devtool = "#source-map";
    // http://vue-loader.vuejs.org/en/workflow/production.html
    module.exports.plugins = (module.exports.plugins || []).concat([
        new webpack.DefinePlugin({
            "process.env": {
                NODE_ENV: '"production"',
            },
        }),
        new webpack.optimize.UglifyJsPlugin({
            sourceMap: false,
            compress: {
                warnings: false,
                drop_debugger: true,
                drop_console: true,
                pure_funcs: ["console.log"], //移除console
            },
        }),
        new webpack.LoaderOptionsPlugin({
            minimize: true,
        }),
    ]);
}